package com.bigegg.employee.service.impl;

import java.util.List;

import com.bigegg.employee.dto.MajorActSignSta;
import com.bigegg.employee.dto.UnitSignCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bigegg.employee.mapper.ActivitySignCompMapper;
import com.bigegg.employee.domain.ActivitySignComp;
import com.bigegg.employee.service.IActivitySignCompService;

/**
 * 单位签到Service业务层处理
 *
 * @author sun
 * @date 2022-08-16
 */
@Service
public class ActivitySignCompServiceImpl implements IActivitySignCompService {
    @Autowired
    private ActivitySignCompMapper activitySignCompMapper;

    /**
     * 查询单位签到
     *
     * @param id 单位签到主键
     * @return 单位签到
     */
    @Override
    public ActivitySignComp selectActivitySignCompById(Long id) {
        return activitySignCompMapper.selectActivitySignCompById(id);
    }

    /**
     * 查询单位签到列表
     *
     * @param activitySignComp 单位签到
     * @return 单位签到
     */
    @Override
    public List<ActivitySignComp> selectActivitySignCompList(ActivitySignComp activitySignComp) {
        return activitySignCompMapper.selectActivitySignCompList(activitySignComp);
    }

    /**
     * 新增单位签到
     *
     * @param activitySignComp 单位签到
     * @return 结果
     */
    @Override
    public int insertActivitySignComp(ActivitySignComp activitySignComp) {
        return activitySignCompMapper.insertActivitySignComp(activitySignComp);
    }

    /**
     * 修改单位签到
     *
     * @param activitySignComp 单位签到
     * @return 结果
     */
    @Override
    public int updateActivitySignComp(ActivitySignComp activitySignComp) {
        return activitySignCompMapper.updateActivitySignComp(activitySignComp);
    }

    /**
     * 批量删除单位签到
     *
     * @param ids 需要删除的单位签到主键
     * @return 结果
     */
    @Override
    public int deleteActivitySignCompByIds(Long[] ids) {
        return activitySignCompMapper.deleteActivitySignCompByIds(ids);
    }

    /**
     * 删除单位签到信息
     *
     * @param id 单位签到主键
     * @return 结果
     */
    @Override
    public int deleteActivitySignCompById(Long id) {
        return activitySignCompMapper.deleteActivitySignCompById(id);
    }

    @Override
    public boolean hasSigned(Long activity_id, Long unitId, Long stuId) {
        return activitySignCompMapper.hasSigned(activity_id, unitId, stuId) > 0;
    }

    /**
     * 单位活动所有签到数
     *
     * @param actId 活动ID
     * @return 签到数
     */
    public int getCountSign(Long actId) {
        return activitySignCompMapper.countSign(actId);
    }

    /**
     * 单位获取活动班级签到数
     *
     * @param actId       活动
     * @param classIdList 班级list
     * @return 签到数
     */
    public int getCountClassSign(Long actId, List<Long> classIdList) {
        return activitySignCompMapper.countClassSign(actId, classIdList);
    }

    /**
     * 查询专业单位签到情况
     * @param actId 活动ID
     * @param deptId 部门ID
     */
    public List<MajorActSignSta> getCountMajorSign(Long actId, Long deptId) {
        return activitySignCompMapper.countMajorSign(actId, deptId);
    }

    /**
     * 查询单位签到情况
     * @param activityId activityId
     * @return UnitSignCount
     */
    public List<UnitSignCount> getUnitSignCount(Long activityId) {
       return activitySignCompMapper.getUnitSignCount(activityId);
    }
}
